package com.naizhuai.receiver;

import android.content.Context;
import android.content.Intent;

import com.naizhuai.Model.AccountHelper;
import com.naizhuai.Model.ModelProvider;
import com.naizhuai.Model.db.user.PersonUserBean;
import com.naizhuai.Model.db.user.UserDataSourse;
import com.naizhuai.Model.db.user.UserRepository;
import com.naizhuai.R;
import com.naizhuai.ui.entity.Bus.Bus;
import com.naizhuai.ui.entity.JumpBean;
import com.naizhuai.ui.entity.mainbusiness.ActionBaseBean;
import com.naizhuai.ui.entity.mainbusiness.TargetDetailsBean;
import com.naizhuai.ui.mianbusiness.action.ActionBrightSpotActivity;
import com.naizhuai.ui.mianbusiness.action.ActionExamineActivity;
import com.naizhuai.ui.mianbusiness.setting.ThankCardPagerActivity;
import com.naizhuai.ui.mianbusiness.target.TargetDetailsActivity;
import com.naizhuai.ui.msgmanager.MsgNotifyActivity;
import com.naizhuai.ui.msgmanager.PersonExamineActivity;
import com.naizhuai.ui.task.ActionSetting1Activity;
import com.naizhuai.ui.task.TaskDetialActivity;
import com.naizhuai.ui.web.WebActivity;
import com.naizhuai.util.IntentUtils;
import com.naizhuai.util.RxBus;

/**
 * @author：lichenxi
 * @date 2018/6/21 15
 * email：525603977@qq.com
 * Fighting
 */
public class PushCommonJump {
    //处理推送过来的自定义消息
   public  static  void  handlePush(Context context,JumpBean jumpBean){
       switch (jumpBean.viewId) {
           case JumpBean.NOTIFY_ADDCOMPANY:
               //更新用户数据  更新界面 现在大问题 就是更新界面的问题了
               ModelProvider.provideUserRepository().updateLoginUser(new UserDataSourse.GetUserCallback() {
                   @Override
                   public void onUserLoaded(PersonUserBean user) {
                       AccountHelper.saveComPany(user);
                       RxBus.getDefault().postSticky(new Bus.UserChange());
                   }
                   @Override
                   public void onDataNotAvailable() {

                   }
               });
               break;
       }
   }

    //处理点击通知栏跳转的
    public  static void notifyJump(Context context,JumpBean jumpBean){
        if (jumpBean==null){
            return;
        }
//        Intent intent=new Intent();
//        intent.setClass(context, PersonExamineActivity.class);
//        context.startActivity(intent);
        switch (jumpBean.viewId){
           case JumpBean.JUMPH5:
               WebActivity.start(context,context.getString(R.string.app_name),jumpBean.viewProperty.url);
               break;
           case JumpBean.JUMPQuestion_Detial:
               IntentUtils.startActivityWithString(ActionBaseBean.ACTION_ID_KEY,jumpBean.viewProperty.questionId, context, ActionSetting1Activity.class);
               break;
           case JumpBean.JUMPTarget_Detial:
               IntentUtils.startActivityWithString(TargetDetailsBean.GOAL_ID_KEY, new String[]{jumpBean.viewProperty.goalId}, context, TargetDetailsActivity.class);
               break;
           case JumpBean.JUMPTask_Detial:
               TaskDetialActivity.start(context,jumpBean.viewProperty.taskId);
               break;
            case JumpBean.JUMPQuestion_Check:
                ActionExamineActivity.startActivity(context, jumpBean.viewProperty.questionId);
                break;
            case JumpBean.JUMPPerson_Check:
                PersonExamineActivity.start(context);
                break;
            case JumpBean.JUMPMSG_LIST:
                String categoryId = jumpBean.viewProperty.categoryId;
                MsgNotifyActivity.start(context, categoryId);
                break;
           case JumpBean.JUMPThanksPage:
               ThankCardPagerActivity.startActivity(context);
               break;
            case JumpBean.JUMPBright_Spot:
                Intent intent=new Intent(context,ActionBrightSpotActivity.class);
                intent.putExtra(ActionBaseBean.ACTION_ID_KEY,jumpBean.viewProperty.questionId);
                context.startActivity(intent);
                break;

       }
    }
}
